package com.example.demo.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyConfig implements WebMvcConfigurer {
   @Autowired
   private LoginInterceptor loginInterceptor;

    /**
     *      配置拦截规则
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
            registry.addInterceptor(loginInterceptor)
                    .addPathPatterns("/**")//拦截所有url
                    . excludePathPatterns("/login.html")
                    .excludePathPatterns("/reg.html")
                    .excludePathPatterns("/blog_list.html")
                    .excludePathPatterns("/blog_content.html")
                    .excludePathPatterns("/blog_content.html")
                    .excludePathPatterns("/css/**")//css下的所有资源都不拦截
                    .excludePathPatterns("/editor.md/**")
                    .excludePathPatterns("/img/**")
                    .excludePathPatterns("/js/**")
                    .excludePathPatterns("/user/login")
                    .excludePathPatterns("/user/reg")
                    .excludePathPatterns("/art/getdetail")
                    .excludePathPatterns("/art/addrcount")
                    .excludePathPatterns("/user/islogin")
                    .excludePathPatterns("/art/mylist ")
                    .excludePathPatterns("/art/getlistbypage")
                    .excludePathPatterns("/art/getcount")
                    .excludePathPatterns("/img/**")
                    .excludePathPatterns("/captcha/verify")
                    .excludePathPatterns("/captcha/code")
                    .excludePathPatterns("/captcha/checkCaptcha")
                    .excludePathPatterns("/user/checkCaptcha")
                    .excludePathPatterns("/art/editsave")
                    .excludePathPatterns("/art/mydraftlist")
                    .excludePathPatterns("/art/timeoutupdate")
                    .excludePathPatterns("/art/timeout")
                    .excludePathPatterns("/user/modify")
                    .excludePathPatterns("/art/addtimeout")
                    .excludePathPatterns("/comment/submit")
                    .excludePathPatterns("/comment/init");
//                    .excludePathPatterns("/img/get");

    }
}
